package com.desay.pangoo.itmt.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import lombok.Data;

/**
 * @author uidq1163 on [2022年09月22日上午10:16:03]
 * @Description： work group Tech classification 工作组技术分类
 * @Modified By： [修改人] on [修改日期] for [修改说明]
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "tech_classification", uniqueConstraints = {@UniqueConstraint(columnNames = {"work_group_id","classification_name"})})
@Data
public class TechClassificationEntity extends BaseEntity implements Serializable {

	private static final long serialVersionUID = 5849780253845075770L;

	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", columnDefinition = "bigint COMMENT '主键'")
    private Long id;

    @Column(name = "classification_name", nullable = false, columnDefinition = "varchar(255) COMMENT '分类名称'")
    private String classificationName;
    
    @ManyToOne(fetch = FetchType.EAGER, optional = true)
	@JoinColumn(name = "work_group_id")
	private WorkGroupEntity workGroup;

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        TechClassificationEntity other = (TechClassificationEntity) obj;
        if (id == null) {
            if (other.id != null) {
                return false;
            }
        } else if (!id.equals(other.id)) {
            return false;
        }
        return true;
    }
}
